//
//  HttpClient.h
//  JMZGO
//
//  Created by apple  on 17/7/18.
//  Copyright © 2017年 JMZ. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

@interface HttpClient : AFHTTPSessionManager

+ (instancetype)sharedInstance;

/**
 *  发送一个POST请求
 *
 *  @param url     请求路径
 *  @param params  请求参数
 *  @param success 请求成功后的回调
 *  @param failure 请求失败后的回调
 */
+ (void)postWithURL:(NSString *)url params:(NSDictionary *)params success:(void (^)(id json))success failure:(void (^)(NSError *error))failure;

- (void)request:(NSString *)url
         params:(NSDictionary *)params
        success:(void(^)(NSObject *response))success
        failure:(void(^)(NSError *error))failure;

/**
 * POST请求获取JSon数据
 */
+ (void)requestJson:(NSString *)url
             params:(NSDictionary *)params
            success:(void(^)(NSDictionary *data))success
            failure:(void(^)(NSError *error))failure;


- (void)requestGet:(NSString *)url
         params:(id)params
        success:(void(^)(id response))success
        failure:(void(^)(NSError *error))failure;
/**
 * GET请求
 */
+ (void)requestGet:(NSString *)url
             params:(id)params
            success:(void(^)(id response))success
            failure:(void(^)(NSError *error))failure;

/**
 * POST请求获取返回值不是JSon数据
 */
+ (void)requestPost:(NSString *)url
             params:(NSDictionary *)params
            success:(void(^)(NSInteger result))success
            failure:(void(^)(NSError *error))failure;

- (void)requestPost:(NSString *)url
             params:(NSDictionary *)params
            success:(void(^)(id response))success
            failure:(void(^)(NSError *error))failure;
@end
